/*
Navicat SQL Server Data Transfer

Source Server         : 172.16.100.172-DEV
Source Server Version : 110000
Source Host           : 172.16.100.172:1433
Source Database       : ServiceCenter
Source Schema         : dbo

Target Server Type    : SQL Server
Target Server Version : 110000
File Encoding         : 65001

Date: 2016-05-06 09:59:44
*/


-- ----------------------------
-- Table structure for ServiceConfig
-- ----------------------------
DROP TABLE [dbo].[ServiceConfig]
GO
CREATE TABLE [dbo].[ServiceConfig] (
[ConsumerAppId] varchar(50) NOT NULL ,
[ProviderAppId] varchar(50) NOT NULL ,
[IsDisabled] bit NOT NULL ,
[CreateTime] datetime NOT NULL ,
[LastUpdateTime] datetime NOT NULL ,
[LastUpdateTicks] bigint NULL 
)


GO

-- ----------------------------
-- Table structure for ServiceDependencySampling
-- ----------------------------
DROP TABLE [dbo].[ServiceDependencySampling]
GO
CREATE TABLE [dbo].[ServiceDependencySampling] (
[Id] bigint NOT NULL IDENTITY(1,1) ,
[ConsumerAppId] varchar(50) NOT NULL ,
[ProviderAppId] varchar(50) NOT NULL ,
[BeginTime] datetime NOT NULL ,
[EndTime] datetime NOT NULL ,
[SamplingElapsedSeconds] float(53) NOT NULL ,
[TotalRequestTimes] bigint NOT NULL ,
[TotalFailTimes] bigint NOT NULL ,
[TotalRequestElapsedMilliseconds] float(53) NOT NULL 
)


GO
DBCC CHECKIDENT(N'[dbo].[ServiceDependencySampling]', RESEED, 63863)
GO

-- ----------------------------
-- Table structure for ServiceMetadata
-- ----------------------------
DROP TABLE [dbo].[ServiceMetadata]
GO
CREATE TABLE [dbo].[ServiceMetadata] (
[AppId] varchar(50) NOT NULL ,
[ApiName] varchar(200) NOT NULL ,
[Host] varchar(100) NULL ,
[ApiPath] varchar(500) NULL ,
[HttpMethod] varchar(50) NOT NULL ,
[CreateTime] datetime NULL ,
[LastUpdateTime] datetime NULL ,
[Description] nvarchar(500) NULL ,
[Owner] nvarchar(50) NULL ,
[LastUpdateTicks] bigint NULL 
)


GO

-- ----------------------------
-- View structure for ServiceDependency
-- ----------------------------
DROP VIEW [dbo].[ServiceDependency]
GO
CREATE VIEW [dbo].[ServiceDependency] AS 
select DISTINCT ConsumerAppId,ProviderAppId from ServiceDependencySampling WITH(NOLOCK)
GO

-- ----------------------------
-- Indexes structure for table ServiceConfig
-- ----------------------------
CREATE UNIQUE INDEX [ConsumerAppId_ProviderAppId] ON [dbo].[ServiceConfig]
([ConsumerAppId] ASC, [ProviderAppId] ASC) 
WITH (IGNORE_DUP_KEY = ON)
GO

-- ----------------------------
-- Primary Key structure for table ServiceConfig
-- ----------------------------
ALTER TABLE [dbo].[ServiceConfig] ADD PRIMARY KEY ([ProviderAppId], [ConsumerAppId])
GO

-- ----------------------------
-- Indexes structure for table ServiceDependencySampling
-- ----------------------------
CREATE INDEX [ServiceDependencySampling_ConsumerAppId_ProviderAppId_BeginTime_EndTime] ON [dbo].[ServiceDependencySampling]
([ConsumerAppId] ASC, [ProviderAppId] ASC, [BeginTime] ASC, [EndTime] ASC) 
GO

-- ----------------------------
-- Primary Key structure for table ServiceDependencySampling
-- ----------------------------
ALTER TABLE [dbo].[ServiceDependencySampling] ADD PRIMARY KEY ([Id])
GO

-- ----------------------------
-- Indexes structure for table ServiceMetadata
-- ----------------------------
CREATE UNIQUE CLUSTERED INDEX [ServiceMetadata_AppId_ApiName_HttpMethod] ON [dbo].[ServiceMetadata]
([AppId] ASC, [ApiName] ASC, [HttpMethod] ASC) 
WITH (IGNORE_DUP_KEY = ON)
GO
